import logging
import os

import allure

# from config.config import *

# 导入ocr识别方法
from untils.docr_until import get_res_sn_captcha

@allure.step("核心1.解析请求数据")
def analyse_case(case):
    # 核心步骤一：解析请求数据
    method = case["method"]
    url = os.environ["URL"] + case["path"]
    headers = eval(case["headers"]) if isinstance(case["headers"], str) else None
    data = eval(case["data"]) if isinstance(case["data"], str) else None
    params = eval(case["params"]) if isinstance(case["params"], str) else None
    json = eval(case["json"]) if isinstance(case["json"], str) else None
    files = eval(case["files"]) if isinstance(case["files"], str) else None

    requests_data = {
        "method": method,
        "url": url,
        "headers": headers,
        "data": data,
        "params": params,
        "json": json,
        "files": files
    }
    # 1.日志打印--返回解析后的请求数据
    logging.info("1.解析后的请求数据是：{}".format(requests_data))
    # 添加allure报告附件
    allure.attach(f"{requests_data}", name="解析请求数据的结果")
    return requests_data